module Shamela
  Section = Struct.new(:id,:tit,:lvl,:sub,:parent,:description,:documents,:subsections)
  class Section
    def initialize(csv_row, header)
      header.each_with_index do |name, i|
        self.send("#{name}=", csv_row[i])
      end
      self.documents = []
      self.subsections = []
    end
    
    def ==(other_section)
      self.id == other_section.id
    end
    
    def eql?(other_section)
      self.id.eql?(other_section.id)
    end
    
    def hash
      self.id.hash
    end
    
    def to_db
      ::Section.new(:title=>self.tit, :description=>self.description)
    end
  end
end
